package com.itqf.proxy.static_proxy1.impl;

import com.itqf.proxy.static_proxy1.GoodsService;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/11/10
 * @Time: 上午10:57
 */
public class ProxyGoodsServiceImpl implements GoodsService {
    GoodsService goodsService;

    public ProxyGoodsServiceImpl(GoodsService goodsService){
        this.goodsService = goodsService;
    }

    @Override
    public void addGoods() {
        try {
            System.out.println("开启事务");
            goodsService.addGoods();
            System.out.println("日记录入");
            System.out.println("提交事务");
        } catch (Exception e) {
            System.err.println("回滚事务");
        }
    }

    @Override
    public void updateOrder() {
        try {
            System.out.println("开启事务");
            goodsService.updateOrder();
            System.out.println("日记录入");
            System.out.println("提交事务");
        } catch (Exception e) {
            System.err.println("回滚事务");
        }
        }
}
